﻿namespace OpenPms.Data;
public class TGuestBase : TBase
{
    /// <summary>
    /// GuestId，CheckIn、AddMate时，可空
    /// </summary>
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public Guid Id { get; set; } = Guid.NewGuid();
    [DisplayName("订单号")]
    [Obsolete]
    public Guid OrderId { get; set; }
    [DisplayName("姓名")]
    [StringLength(64)]
    public string Name { get; set; } = default!;
    [StringLength(64)]
    [DisplayName("证件号码")]
    public string IdNo { get; set; } = default!;
    [DisplayName("证件类型")]
    public EIdType IdType { get; set; }
    [Obsolete]
    [DisplayName("偏好")]
    public string? Preference { get; set; }
    [DisplayName("入住日期")]
    public DateTime DTCheckIn { get; set; }
    [DisplayName("退房日期")]
    public DateTime? DTCheckOut { get; set; }
    [Display(Name = "手机号码", Order = -1)]
    public string? Mobile { get; set; }
}

[Index(nameof(HotelId), nameof(IdNo))]
public class TGuest : TGuestBase
{

    [DisplayName("退房")]
    public bool IsCheckOut { get; set; }
    [Obsolete]
    [JsonIgnore]
    [ForeignKey(nameof(OrderId))]
    public TOrder Order { get; set; } = default!;


    public TGuest() { }
    public TGuest(InfoIdCard infoIdCard, Guid orderId, DateTime dtCheckin, int hotelId)
    {
        OrderId = orderId;
        DTCheckIn = dtCheckin;
        HotelId = hotelId;
        Name = infoIdCard.TrueName;
        IdNo = infoIdCard.No;
        IdType = infoIdCard.IdType;
        Mobile = infoIdCard.Mobile;
    }
}

